package cn.itsource.xhy.pay.service.impl;

import cn.itsource.xhy.basic.service.impl.BaseServiceImpl;
import cn.itsource.xhy.pay.contants.PayContants;
import cn.itsource.xhy.pay.domain.AliPayInfo;
import cn.itsource.xhy.pay.domain.PayBill;
import cn.itsource.xhy.pay.mapper.AliPayInfoMapper;
import cn.itsource.xhy.pay.mapper.PayBillMapper;
import cn.itsource.xhy.pay.service.IPayBillService;
import cn.itsource.xhy.pay.utils.AliPayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PayBillServiceImpl extends BaseServiceImpl<PayBill> implements IPayBillService {


    @Autowired
    private AliPayInfoMapper aliPayInfoMapper;

    @Autowired
    private PayBillMapper payBillMapper;

    @Override
    public String pay(PayBill payBill) {
        //不同的支付方式
        switch (payBill.getPayChannel()){
            case PayContants.ALIPAY:
                //支付宝支付
                //查询到支付信息
                AliPayInfo aliPayInfo = aliPayInfoMapper.findById(1L);
                String result = AliPayUtils.aliPay(payBill,aliPayInfo);
                return result;
            case PayContants.WXPAY:

                break;
            case PayContants.UNIONPAY:

                break;

        }
        return null;
    }

    @Override
    public PayBill findByOrderSn(String orderSn) {
        return payBillMapper.findByOrderSn(orderSn);
    }
}
